//顶部
$.ajax({
	type: "post",
	url: Urls + "/api/Cms/GetCmsDetailV1",
	data: JSON.stringify({
		"Id": Id,
		"MemberToken": ""
	}),
	success: function(res) {
		var data = res.Data;
		console.log(data)
		var Title = data.Title;
		DocType = data.DocType;
		var ordinary_content = '<h3>' + Title + '</h3>' +
			'<p class="p_time"><span>' + data.UpdateDate + '</span>&nbsp;&nbsp;' + data.Author + '</p>' +
			'<p class="p_num">阅读数量<span>' + data.HitCount + '</span></p>';
		'<div class="content_tails">' + data.Content + '</div>';
		$('.content .top_content').append(ordinary_content)
		if(data.DocType == "NEWSLIST") {
			if(data.NewType == "0") {
				document.querySelector(".content_tails").innerHTML = data.Content;
			} else if(data.NewType == "1") {
				var PhotoList = res.Data.PhotoList;
				JSON.parse(PhotoList).forEach(item => {
					var Photo_new =
						`<div>` +
						`<img src="${item.PicUrl}" style="width:100%;" />` +
						`<p style="" >${item.ListContent}</p>` +
						`</div>`;
					$('.content_tails').append(Photo_new)
				});
			}
			return_newlist();
		} else if(data.DocType == "VIDEOLIST") {
//			var video_ = '<div id="videos"><img src="img/videoimg.png" /></div>'
//			var video_ = '<video id="video" x-webkit-airplay="true" x5-playsinline="true" webkit-playsinline="true"  width="100%" src=' + data.AttachmentUrl[0] + ' type="mp4" controls="controls" poster=' + data.ThumbnailUrl[0] + '></video>';
			var video_ = '<video id="video" x-webkit-airplay="true" x5-playsinline="true" webkit-playsinline="true"  width="100%" type="mp4" controls="controls" poster=' + data.ThumbnailUrl[0] + '></video>';
			$('.content_tails #content_small').append(video_);
			return_video();
		} else if(data.DocType == "REGIMEN") {
//						var audio_ = '<div class="audio_content" id="ausio"></div>' +
//							'<audio style="width:100%" src=' + data.AudioUrl[0] + ' controls></audio>';
			var audio_ = '<div id="ausio" class="audio_content"></div>' +
				'<audio id="ain" style="width:100%" controls></audio>';
			$('.content_tails #content_small').append(audio_);
			document.querySelector(".audio_content").innerHTML = data.Content;
			return_regimen();
		}
		//评论接口
		$.ajax({
			type: "post",
			url: Urls + "/api/Cms/GetComment",
			data: JSON.stringify({
				"ObjectId": Id,
				"ParentId": "0",
				"Type": "OBJECT",
				"PageIndex": 1,
				"PageSize": 5,
				"MemberAccount": "",
				"CommentType": DocType
			}),
			success: function(res) {
				var Data = res.Data;
				$('.comment_p span').text(res.TotalCount);
				for(var i = 0; i < Data.length; i++) {
					var Class_comment = '<li>' +
						'<div>' +
						'<div><img src="' + Data[i].Icon + '" /></div>' +
						'<div>' +
						'<p>' + Data[i].Name + '</p>' +
						'<p>' + Data[i].CommentDate + '</p>' +
						'</div>' +
						'<div>' +
						'<img src="img/2.png" />' +
						'<p>' + Data[i].PraiseTime + '</p>' +
						'</div>' +
						'</div>' +
						'<div>' +
						'<p>' + Data[i].Content + '</p>' +
						'</div>' +
						'</li>';
					$('.comments ul').append(Class_comment)
				}
			}
		});

		//轮播图
		$.ajax({
			type: "post",
			url: Urls + "/api/Cms/GetCmsListV2",
			data: JSON.stringify({
				"TypeId": 0,
				"PageIndex": 1,
				"PageSize": 5,
				"IsHot": 0,
				"Keyword": "",
				"DocType": DocType,
				"OrderType": "Time",
				"TopicId": 0,
				"DocId": Id
			}),
			success: function(res) {
				var SpecialList = res.Data.DocList;
				for(var i = 0; i < SpecialList.length; i++) {
					var sweione = '<div class="swiper-slide sweione">' +
						'<img src="' + SpecialList[i].ThumbnailUrl[0] + '" />' +
						'<p>' + SpecialList[i].Title + '</p>' +
						'</div>';
					$('.swiper-wrapper').append(sweione);
				}
				//轮播图
				var mySwiper = new Swiper('.swiper-container', {
					slidesPerView: 2, //'auto'
					observer: true, //修改swiper自己或子元素时，自动初始化swiper
					observeParents: false, //修改swiper的父元素时，自动初始化swiper
					onTransitionEnd: function(swiper) {
						if(swiper.progress == 1) {
							swiper.activeIndex = swiper.slides.length - 1
						}
					}
				})
			}
		});

	}
});

//getUrlParam(url) {
//	var search = url.split("?")[1];
//	console.log(search);
//	var paramsSplitStrArr = search.split("&");
//	var paramObj = {};
//	var tempArr = [];
//	paramsSplitStrArr.forEach(item => {
//		tempArr = item.split("=");
//		paramObj[tempArr[0]] = tempArr[1];
//	});
//	return paramObj;
//};